package org.vectrics.user.web.struts;

import javax.servlet.jsp.JspException;

import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.struts.VectricsActionData;
import org.vectrics.struts.VectricsStrutsAction;
import org.vectrics.user.Person;

public class ShowPasswordEditAction extends VectricsStrutsAction {

	protected Person getPersonWithPassword(VectricsActionData actionData) {
		String personIdParam = actionData.getRequest().getParameter("personId");
		Long personId = new Long(personIdParam);
		Person person = CoreServiceLocator.getPersonService().findPersonById(personId);
		return(person);
	}
	
	@Override
	protected String doExecute(VectricsActionData actionData)
			throws JspException {
		
		Person person = this.getPersonWithPassword(actionData);
		UserPasswordForm form = new UserPasswordForm();
		form.setPersonId(person.getId().toString());
		form.setUserName(person.getUser().getUserName());
		form.setPersonName(person.getName());
		actionData.setForm(form);
		
		return "success";
	}

}
